<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Continue</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Continue</h1>

<p>Skips the rest of the current <a href="Loop.htm">loop</a> iteration and begins a new one. Valid inside any kind of <a href="Loop.htm">loop</a>.</p>

<pre class="Syntax">Continue [, LoopLabel]</pre>
<p><span class="ver">[AHK_L 59+]:</span> If specified, LoopLabel identifies which loop this statement should apply to; either by <a href="../misc/Labels.htm">label name</a> or numeric nesting level. If omitted or 1, this statement applies to the innermost loop in which it is enclosed. LoopLabel must be a constant value - variables and expressions are not supported. If a <a href="../misc/Labels.htm">label</a> is specified, it must point directly at a loop command.</p>
<p>Continue behaves the same as reaching the loop's closing brace:</p>
<ol>
  <li>It increases <a href="../Variables.htm#Index">A_Index</a> by 1.</li>
  <li>It skips the rest of the loop's body.</li>
  <li>The loop's condition (if it has one) is checked to see if it is satisified. If so, a new iteration begins; otherwise the loop ends.</li>
</ol>
<p>The use of <a href="Break.htm">Break</a> and Continue are encouraged over <a href="Goto.htm">goto</a> since they usually make scripts more readable and maintainable.</p>
<h3>Related</h3>
<p><a href="Break.htm">Break</a>, <a href="Loop.htm">Loop</a>, <a href="Until.htm">Until</a>, <a href="While.htm">While-loop</a>, <a href="For.htm">For-loop</a>, <a href="Block.htm">Blocks</a>, <a href="../misc/Labels.htm">Labels</a></p>

<h3>Example</h3>
<pre class="NoIndent"><em>; This example displays 5 MsgBoxes, one for each number between 6 and 10.
; Note that in the first 5 iterations of the Loop, the &quot;continue&quot; command
; causes the loop to start over before it reaches the MsgBox line.</em>
Loop, 10
{
    if A_Index &lt;= 5
        continue
    MsgBox %A_Index%
}</pre>
<pre class="NoIndent"><em>; Continue the outer loop from within a nested loop.</em>
outer:
Loop 3
{
    x := A_Index
    Loop 3
    {
        if (x*A_Index = 4)
            <b>continue outer</b>  <em>; Equivalent to <b>continue 2</b> or <b>goto continue_outer</b>.</em>
        MsgBox %x%,%A_Index%
    }
    continue_outer: <em>; For goto.</em>
    ErrorLevel:=ErrorLevel <em>; Prior to revision 57, labels could not point to the end of a block.</em>
}
</pre>

</body>
</html>
